<template>
  <div class="content">
    <div class="chance">
      <div class="select">
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
          <el-tab-pane label="入职" name="enter">
            <div slot="label" class="tab-label-container">
              <div class="tab-label-title">入职 ({{ 222 }})</div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="离职" name="leave">
            <div slot="label" class="tab-label-container">
              <div class="tab-label-title">离职 ({{ 222 }})</div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="退休" name="retire">
            <div slot="label" class="tab-label-container">
              <div class="tab-label-title">退休 ({{ 222 }})</div>
            </div>
          </el-tab-pane>
        </el-tabs>
        <div class="block">
          <el-date-picker v-model="value1" type="year" placeholder="选择年">
          </el-date-picker>
        </div>
        <div class="block">
          <el-date-picker v-model="value2" type="month" placeholder="选择月">
          </el-date-picker>
        </div>
      </div>
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        class="query-form"
      >
        <el-form-item>
          <el-input
            v-model="queryParams.employeeTel"
            placeholder="支持姓名、工号、手机号搜索"
            clearable
            size="small"
            @keyup.enter.native="searchMethod"
          >
           <i slot="suffix" class="el-input__icon el-icon-search"></i>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button size="mini">导出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="context">
      <div class="table">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column type="index" label="序号"> </el-table-column>
          <el-table-column prop="id" label="所属组织"> </el-table-column>
          <el-table-column prop="name" sortable label="工号"> </el-table-column>
          <el-table-column prop="id" sortable label="中文姓名">
          </el-table-column>
          <el-table-column prop="name" label="在职状态"> </el-table-column>
          <el-table-column prop="id" sortable label="入职日期">
          </el-table-column>
          <el-table-column prop="name" sortable label="转正日期">
          </el-table-column>
          <el-table-column prop="id" sortable label="开始缴纳日期">
          </el-table-column>
          <el-table-column prop="name" sortable label="停止缴纳日期">
          </el-table-column>
          <el-table-column prop="name" label="缴纳状态"> </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button @click="start(scope.row)" type="text" size="small"
                >开始缴纳</el-button
              >
              <el-button type="text" size="small" @click="end(scope.row)"
                >停止缴纳</el-button
              >
            </template>
          </el-table-column>
          <el-table-column align="center" width="50">
            <template slot="header">
              <el-popover placement="bottom-start" width="100" trigger="click">
                <el-checkbox-group v-model="checkedTableColumns">
                  <div style="display: flex; flex-direction: column">
                    <el-checkbox label="选项">选项</el-checkbox>
                  </div>
                </el-checkbox-group>
                <i
                  class="el-icon-s-tools"
                  @click="clickReset"
                  style="font-size: 25px"
                  slot="reference"
                ></i>
              </el-popover>
            </template>
          </el-table-column>
        </el-table>
        <start-time :startDialog="startDialog" @close="closeStart"></start-time>
        <end-time :endDialog="endDialog" @close="closeEnd"></end-time>
      </div>
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :current-page="queryParams.current"
        :page-size="queryParams.size"
        :page-sizes="[10, 20, 30, 40]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="20"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import startTime from "./startTime.vue";
import endTime from "./endTime.vue";
export default {
  components: {
    startTime,
    endTime,
  },
  data() {
    return {
      value1:'',
      value2:'',
      activeName: "first",
      startDialog: false,
      endDialog: false,
      enter: 0,
      leave: 0,
      retire: 0,
      tableData: [
        {
          id: "12987122",
          name: "王小虎",
          amount1: "234",
          amount2: "3.2",
          amount3: 10,
        },
        {
          id: "12987122",
          name: "王小虎",
          amount1: "234",
          amount2: "3.2",
          amount3: 10,
        },
        {
          id: "12987122",
          name: "王小虎",
          amount1: "234",
          amount2: "3.2",
          amount3: 10,
        },
      ],
      queryParams: {
        employeeCode: null,
        employeeName: null,
        employeeTel: null,
        employeeJoinStatus: null,
        employeeFormalStatus: null,
        employeeLeaveStatus: null,
        employeeRetiredStatus: null,
        current: 1, //当前页码
        size: 10, //每页显示数量
      },
    };
  },
  methods: {
    handleClick(tab, event) {
      let name = tab.name;
      switch (name) {
        case "enter":
          this.queryParams.employeeStatus = "2";
          break;
        case "leave":
          this.queryParams.employeeStatus = "3";
          break;
        case "retire":
          this.queryParams.employeeStatus = "4";

          break;
        default:
          this.queryParams.employeeStatus = "2";

          break;
      }
      this.getPageList();
    },
    clickReset() {
      this.reset = !this.reset;
    },
    resetQuery() {
      this.queryParams = {
        employeeCode: null,
        employeeName: null,
        employeeTel: null,
        employeeStatus: "2",
        size: 10,
        current: 1,
      };
      this.getPageList();
    },
    // 翻页
    handleCurrentChange(val) {
      this.queryParams.current = val;
      this.getPageList();
    },
    // 开始缴纳弹窗
    start() {
      this.startDialog = true;
    },
    closeStart(params) {
      this.startDialog = params;
    },
    // 停止缴纳弹窗
    end() {
      this.endDialog = true;
    },
    closeEnd(params) {
      this.endDialog = params;
    },
  },
};
</script>
<style scoped>
.el-table {
  margin-top: 20px;
}
.el-tabs {
  margin: 0 20px;
}
.el-tabs__item {
  font-size: 16px;
  font-weight: bold;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.chance {
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.context {
  padding-left: 20px;
}
.select .el-dropdown-link {
  color: black;
  border: 1px solid #ccc;
  padding: 10px;
  margin-right: 20px;
  border-radius: 5px;
}
.select {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.el-date-editor {
  width: 120px;
  margin-right: 20px;
}
.el-pagination {
  margin-top: 20px;
  float: right;
}
</style>